package com.cg.design.graphicdesignpattern.builder;

import org.junit.Test;

import java.util.Scanner;

/**
 * Builder建造者模式测试类
 *
 * @program: LeetCode->BuilderTest
 * @description: Builder建造者模式测试类
 * @author: cg
 * @create: 2022-03-20 20:53
 **/
public class BuilderTest {

    @Test
    public void testBuilder() {
        Director director;
        Scanner scanner = new Scanner(System.in);
        System.out.print("plain(纯文本编写文档)\nhtml(HTML编写文档)\nplease input:");
        String input = scanner.next();
        if ("plain".equals(input)) {
            TextBuilder textBuilder = new TextBuilder();
            director = new Director(textBuilder);
            director.construct();
            System.out.println(textBuilder.getResult());
        } else if ("html".equals(input)) {
            HTMLBuilder htmlBuilder = new HTMLBuilder();
            director = new Director(htmlBuilder);
            director.construct();
            System.out.println(htmlBuilder.getResult()+" 文件编写完成");
        } else {
            System.out.println("input error");
        }
    }

}
